<template>
  <div class="page-bg">
    <div class="ta-search-box">
      <el-form ref="form" :model="searchForm" label-width="100px" size="mini">
        <el-form-item label="账号：" prop="userId">
          <el-input v-model="searchForm.userId" style="width: 340px" disabled />
        </el-form-item>

        <el-form-item label="金额：" prop="amount">
          <el-input v-model="searchForm.amount" style="width: 340px" disabled />
        </el-form-item>

        <el-form-item label="日期：" prop="createTime">
          <el-input
            v-model="searchForm.createTime"
            style="width: 340px"
            disabled
          />
        </el-form-item>

        <el-form-item label="支付状态：" prop="payStatus">
          <el-input
            v-model="searchForm.payStatus"
            style="width: 340px"
            disabled
          />
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import { gePayInfo } from "@/api/modules/user";
import Constants from "@/constants";
export default {
  name: "finRecord",
  data() {
    return {
      searchForm: {
        userId: 0,
        id: 0,
        amount: 0,
        createTime: 0,
        payStatus: 1,
      },
      roleValue: 2,
      typeOptions: [
        {
          value: 0,
          label: "指纹算法",
        },
        {
          value: 1,
          label: "笔迹算法",
        },
      ],
      statusOptions: [
        // {
        //   value: 0,
        //   label: "全部",
        // },
        {
          value: 1,
          label: "已支付",
        },
        {
          value: 2,
          label: "未支付",
        },
      ],
      urgentOptions: [
        {
          value: 0,
          label: "全部",
        },
        {
          value: 1,
          label: "加急",
        },
      ],
      resultOptions: [
        {
          value: 0,
          label: "假",
        },
        {
          value: 1,
          label: "真",
        },
      ],
      dialogFormVisible: false,
      dialogForm: {
        comment: "",
        result: 0,
      },
      dialogRules: {
        comment: [
          {
            required: true,
            message: "评论不能为空!",
            trigger: "blur",
          },
        ],
        result: [
          {
            required: true,
            message: "鉴定结果不能为空!",
            trigger: "blur",
          },
        ],
      },
      noReadMessageCount: 0,
      showMessage: 0,
      page: 1,
      pageSize: 5,
      total: 0,
    };
  },
  computed: {
    roleType() {
      return localStorage.getItem("userRole");
    },
  },
  created() {
    this.searchForm.userId = localStorage.getItem("userId");
    this.searchForm.id = localStorage.getItem("userId");
    this.searchForm.createTime = this.generatorDate();
    this.queryTableData();
  },
  methods: {
    queryTableData() {
      gePayInfo(this.searchForm).then((res) => {
        this.loading = false;
        if (res.code == 200) {
          this.searchForm = res.obj;

          if (res.obj.payStatus == 1) {
            this.searchForm.payStatus = "已支付";
          } else {
            this.searchForm.payStatus = "未支付";
          }
        } else {
          this.$message({
            message: res.message,
            type: "error",
          });
        }
      });
    },
    handleCurrentChange(page) {
      this.page = page;
      this.queryTableData();
    },
    handleSizeChange(size) {
      this.pageSize = size;
      this.queryTableData();
    },
    handleClick(row) {
      console.log(row);
    },
    handleAppraisal() {
      this.$router.push({ path: "/appraisal" });
    },
    handSubmit() {
      this.queryTableData();
    },
    editComment(row) {
      console.log(row);
      this.dialogForm.comment = row.comment;
      this.dialogForm.recordId = row.recordId;
      this.dialogForm.result = row.finResult;

      this.dialogFormVisible = true;
    },
    deleteRecord(row) {
      console.log(row);
      let params = {
        recordId: row.recordId,
        userid: localStorage.getItem("userId"),
      };
      deleteIdentRecordByExpert(params).then((res) => {
        if (res.code == 200) {
          this.queryTableData();
        } else {
          this.$message({
            message: res.message,
            type: "error",
          });
        }
      });
    },
    closeDialog() {
      this.dialogFormVisible = false;
    },
    enterDialog() {
      editIdentRecordByExpert(this.dialogForm).then((res) => {
        if (res.code == 200) {
          this.dialogFormVisible = false;
          this.queryTableData();
        } else {
          this.$message({
            message: res.message,
            type: "error",
          });
        }
      });
    },

    formatterResult(row, column) {
      if (row.isTrue == 0) {
        return "假";
      } else if (row.isTrue == 1) {
        return "真";
      } else {
        return "";
      }
    },
    formatterFinResult(row, column) {
      if (row.finResult == 0) {
        return "假";
      } else if (row.finResult == 1) {
        return "真";
      } else {
        return "";
      }
    },
    formatterSignResult(row, column) {
      if (row.signResult == 0) {
        return "假";
      } else if (row.signResult == 1) {
        return "真";
      } else {
        return "";
      }
    },
    formatterType(row, column) {
      if (row.type == 0) {
        return "指纹算法";
      } else if (row.type == 1) {
        return "笔迹算法";
      } else {
        return "";
      }
    },
    generatorDate() {
      let now = new Date();
      let year = now.getFullYear();
      let month = now.getMonth() + 1;
      let day = now.getDate();

      return year + "-" + month + "-" + day;
    },
  },
};
</script>

<style lang="scss" scoped></style>
